<%@ page import="com.deepai.dprsmgr.utils.ErrCode" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@include file="../base_path.jsp" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-cache"/>
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="description" content="">

    <link rel="stylesheet" type="text/css" href="<%=basePath%>/lib/bootstrap/3.3.7/css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" media="screen" href="<%=basePath%>/lib/lobibox/css/lobibox.min.css"/>
    <link rel="stylesheet" type="text/css" media="screen" href="<%=basePath%>/css/mycss.css"/>
    <title>访问权限配置</title>
    <style type="text/css">
        .table {
            margin-bottom: 0px;
        }

        .table > tbody > tr > td .select_level_second {
            padding-left: 12px;
            margin-right: -12px;
            display: none;
        }

        .table > tbody > tr > td .select_level_one {
            font-size: 12px;
            font-weight: bold;
        }

        .table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th, .table > thead > tr > td, .table > thead > tr > th {
            font-size: 12px;
            border: none;
        }

        .table input[type="checkbox"] {
            position: relative;
            top: 2px;
        }

		.btn {
			border-radius: 3px;
		}

		.select_level_one span{
			cursor: pointer;
		}
    </style>
</head>
<body>
<div class="navbar-fixed-top">
    <div class="breadcrumb">
        <span>系统设置</span>/
        <span class="active">访问权限配置</span>
        <span class="pull-right" title="刷新">
            <div class="btn-refresh" onclick="location.replace(location.href);">
            	<img src="<%=basePath%>/images/refresh.png" >
            </div>
        </span>
    </div>
</div>
<div class="container-fluid">
	<div class="container-fluid-main">
    <div class="page-header">
        <h3>访问权限配置</h3>
    </div>
    <div class="container-fluid" style="width: 100%;background: #FFF;">
        <form id="saveAccessEnvMainListConfig" class="form-horizontal bg-info" style="padding: 20px">
            <div class="form-group">
                <label class="col-md-3 control-label">
                    <label class="text-danger" style="margin-right: 5px"></label>访问及许可权限</label>
                <shiro:hasAnyRoles name="role_super_admin">
                    <div class="col-md-6">
                        <button  class="btn btn-primary btn-sm edit">修改</button>
                        <button  class="btn btn-primary btn-sm hide commit">确定</button>
                        <button  class="btn btn-primary btn-sm hide cancel">取消</button>
                    </div>
                </shiro:hasAnyRoles>
            </div>

            <div class="form-group">
                <div class="col-md-8 col-md-offset-2">
                    <table border="0" cellspacing="" cellpadding="" class="table">
                        <tbody id="accessEnvMainList">
                        <!-- <tr>
                            <td>
                                <div class="select_level_one">
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="1" checked> <span class="select_level_one_tit">业务中心</span>
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="0" > 通话详情
                                </div>
                                <div class="select_level_second">
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="1" checked> 业务管理
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="0" > 通话详情
                                </div>

                            </td>
                            <td>
                                <div class="select_level_one">
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="1" checked> <span class="select_level_one_tit">业务中心</span>
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="0" > 通话详情
                                </div>
                                <div class="select_level_second">
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="1" checked> 业务管理
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="0" > 通话详情
                                </div>

                            </td>
                            <td>
                                <div class="select_level_one">
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="1" checked> <span class="select_level_one_tit">业务中心</span>
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="0" > 通话详情
                                </div>
                                <div class="select_level_second">
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="1" checked> 业务管理
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="0" > 通话详情
                                </div>

                            </td>
                        </tr> -->

<!--                        <tr>
                            <td>
                                <div class="select_level_one">
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="1" checked> <span class="select_level_one_tit">业务中心</span>
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="0" > 通话详情
                                </div>
                                <div class="select_level_second">
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="1" checked> 业务管理
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="0" > 通话详情
                                </div>

                            </td>
                            <td>
                                <div class="select_level_one">
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="1" checked> <span class="select_level_one_tit">业务中心</span>
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="0" > 通话详情
                                </div>
                                <div class="select_level_second">
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="1" checked> 业务管理
                                    <input disabled type="checkbox"  name="showDialogViewSwitch" value="0" > 通话详情
                                </div>

                            </td>

                        </tr>
 -->                        </tbody>
                    </table>
                </div>
                <span class="col-md-8 col-md-offset-2 help-block"></span>
            </div>
        </form>
        <form id="functional_access" class="form-horizontal bg-info" style="padding: 20px">
            <div class="form-group">
                <label class="col-md-3 control-label">
                    <label class="text-danger" style="margin-right: 5px"></label>功能开放权限</label>
                <shiro:hasAnyRoles name="role_super_admin">
                    <div class="col-md-6">
                        <button  class="btn btn-primary btn-sm edit">修改</button>
                        <button  class="btn btn-primary btn-sm hide commit">确定</button>
                        <button  class="btn btn-primary btn-sm hide cancel">取消</button>
                    </div>
                </shiro:hasAnyRoles>
            </div>

            <div class="form-group">
                <div class="col-md-8 col-md-offset-2">
                    <div class="col-xs-3 checkbox">
                        <c:choose>
                            <c:when test="${envAccessConfig.callInfoSwitch}">
                                <input disabled type="checkbox"  name="callInfoSwitch" value="1" checked> 测听功能
                            </c:when>
                            <c:otherwise>
                                <input disabled type="checkbox"  name="callInfoSwitch" value="0" > 测听功能
                            </c:otherwise>
                        </c:choose>

                    </div>
                    <div class="col-xs-3 checkbox">
                        <c:choose>
                            <c:when test="${envAccessConfig.showDialogInfoSwitch}">
                                <input disabled type="checkbox"  name="showDialogInfoSwitch" value="1" checked> 显示对话详情文本
                            </c:when>
                            <c:otherwise>
                                <input disabled type="checkbox"  name="showDialogInfoSwitch" value="0" > 显示对话详情文本
                            </c:otherwise>
                        </c:choose>

                    </div>
                    <div class="col-xs-3 checkbox">
                        <c:choose>
                            <c:when test="${envAccessConfig.realTimeMonitorSwitch}">
                                <input disabled type="checkbox"  name="realTimeMonitorSwitch" value="1" checked> 实时监听工作台
                            </c:when>
                            <c:otherwise>
                                <input disabled type="checkbox"  name="realTimeMonitorSwitch" value="0"> 实时监听工作台
                            </c:otherwise>
                        </c:choose>

                    </div>
                    <div class="col-xs-3 checkbox hidden">
                        <c:choose>
                            <c:when test="${envAccessConfig.problemMarkSwitch}">
                                <input disabled type="checkbox"  name="problemMarkSwitch" value="1" checked> 问题标注
                            </c:when>
                            <c:otherwise>
                                <input disabled type="checkbox"  name="problemMarkSwitch" value="0"> 问题标注
                            </c:otherwise>
                        </c:choose>

                    </div>
                    <div class="col-xs-3 checkbox">
                        <c:choose>
                            <c:when test="${envAccessConfig.exportListSwitch}">
                                <input disabled type="checkbox"  name="exportListSwitch" value="1" checked> 导出列表
                            </c:when>
                            <c:otherwise>
                                <input disabled type="checkbox"  name="exportListSwitch" value="0"> 导出列表
                            </c:otherwise>
                        </c:choose>

                    </div>
                    <div class="col-xs-3 checkbox">
                        <c:choose>
                            <c:when test="${envAccessConfig.exportAudioSwitch}">
                                <input disabled type="checkbox"  name="exportAudioSwitch" value="1" checked> 导出录音
                            </c:when>
                            <c:otherwise>
                                <input disabled type="checkbox"  name="exportAudioSwitch" value="0"> 导出录音
                            </c:otherwise>
                        </c:choose>

                    </div>
                    <div class="col-xs-3 checkbox hidden">
                        <c:choose>
                            <c:when test="${envAccessConfig.exportDialogSwitch}">
                                <input disabled type="checkbox"  name="exportDialogSwitch" value="1" checked> 导出对话详情文本
                            </c:when>
                            <c:otherwise>
                                <input disabled type="checkbox"  name="exportDialogSwitch" value="0"> 导出对话详情文本
                            </c:otherwise>
                        </c:choose>

                    </div>
                    <div class="col-xs-3 checkbox hidden">
                        <c:choose>
                            <c:when test="${envAccessConfig.exportAllSwitch}">
                                <input disabled type="checkbox"  name="exportAllSwitch" value="1" checked> 导出全部
                            </c:when>
                            <c:otherwise>
                                <input disabled type="checkbox"  name="exportAllSwitch" value="0"> 导出全部
                            </c:otherwise>
                        </c:choose>

                    </div>
                </div>
                <span class="col-md-8 col-md-offset-2 help-block"></span>
            </div>
        </form>

        <form id="sysCanConfigUserCount" class="form-horizontal bg-info" style="padding: 20px">
            <div class="form-group">
                <label class="col-md-3 control-label">
                    <label class="text-danger" style="margin-right: 5px"></label>系统可配置用户数量</label>
                <shiro:hasAnyRoles name="role_super_admin">
                    <div class="col-md-6">
                        <button  class="btn btn-primary btn-sm edit">修改</button>
                        <button  class="btn btn-primary btn-sm hide commit">确定</button>
                        <button  class="btn btn-primary btn-sm hide cancel">取消</button>
                    </div>
                </shiro:hasAnyRoles>
            </div>
            <%--<div class="form-group">--%>
                <%--<label for="sysConfig_domainAdmin" class="col-md-3 control-label">--%>
                    <%--&lt;%&ndash;<label class="text-danger" style="margin-right: 5px"></label>域管理员</label>&ndash;%&gt;--%>
                <%--<div class="col-md-6">--%>
                    <%--<input disabled type="text" class="form-control input-sm" id="sysConfig_domainAdmin" name="maxDomainAdmin"  value="${envAccessConfig.maxDomainAdmin}">--%>
                    <%--<span class="help-block"></span>--%>
                <%--</div>--%>
            <%--</div>--%>
            <div class="form-group">
                <label for="sysConfig_admin" class="col-md-3 control-label">
                    <label class="text-danger" style="margin-right: 5px"></label>管理员</label>
                <div class="col-md-6">
                    <input disabled type="text" class="form-control input-sm" id="sysConfig_admin" name="maxGeneralAdminCount"  value="${envAccessConfig.maxGeneralAdminCount}">
                    <span class="help-block"></span>
                </div>
            </div>
            <div class="form-group">
                <label for="sysConfig_groupLeader" class="col-md-3 control-label">
                    <label class="text-danger" style="margin-right: 5px"></label>组长</label>
                <div class="col-md-6">
                    <input disabled type="text" class="form-control input-sm" id="sysConfig_groupLeader" name="maxTeamLeaderCount"  value="${envAccessConfig.maxTeamLeaderCount}">
                    <span class="help-block"></span>
                </div>
            </div>
            <div class="form-group">
                <label for="sysConfig_Commissioner" class="col-md-3 control-label">
                    <label class="text-danger" style="margin-right: 5px"></label>专员</label>
                <div class="col-md-6">
                    <input disabled type="text" class="form-control input-sm" id="sysConfig_Commissioner" name="maxProfessionalsCount"  value="${envAccessConfig.maxProfessionalsCount}">
                    <span class="help-block"></span>
                </div>
            </div>
        </form>
		
		<form id="business_config" class="form-horizontal bg-info hidden" style="padding: 20px">
		    <div class="form-group">
		        <label class="col-md-3 control-label">
		            <label class="text-danger" style="margin-right: 5px"></label>业务配置</label>
		        <shiro:hasAnyRoles name="role_super_admin">
		            <div class="col-md-6">
		                <button  class="btn btn-primary btn-sm edit">修改</button>
		                <button  class="btn btn-primary btn-sm hide commit">确定</button>
		                <button  class="btn btn-primary btn-sm hide cancel">取消</button>
		            </div>
		        </shiro:hasAnyRoles>
		    </div>
		    <div class="form-group">
		        <label for="baseRemainCallCnt" class="col-md-3 control-label">
		            <label class="text-danger" style="margin-right: 5px"></label>即将完成</label>
		        <div class="col-md-6">
		            <input disabled type="text" class="form-control input-sm" id="baseRemainCallCnt" name="baseRemainCallCnt"  value="${envAccessConfig.baseRemainCallCnt}">
		            <span class="help-block"></span>
		        </div>
		    </div>
		    <div class="form-group">
		        <label for="sysConfig_groupLeader" class="col-md-3 control-label">
		            <label class="text-danger" style="margin-right: 5px"></label>意图选择倒计时条（毫秒）</label>
		        <div class="col-md-6">
                    <input disabled type="text" class="form-control input-sm" id="callOperateDuration" name="callOperateDuration"  value="${envAccessConfig.callOperateDuration}">
                    <span class="help-block"></span>
		        </div>
		    </div>
		    
		</form>
		

        <form id="access_security" class="form-horizontal bg-info hidden" style="padding: 20px">
            <div class="form-group">
                <label class="col-md-3 control-label">
                    <label class="text-danger" style="margin-right: 5px"></label>访问安全</label>
                <shiro:hasAnyRoles name="role_super_admin">
                    <div class="col-md-6">
                        <button  class="btn btn-primary btn-sm edit">修改</button>
                        <button  class="btn btn-primary btn-sm hide commit">确定</button>
                        <button  class="btn btn-primary btn-sm hide cancel">取消</button>
                    </div>
                </shiro:hasAnyRoles>
            </div>
            <div class="form-group">
                <label for="security_ip" class="col-md-3 control-label">
                    <label class="text-danger" style="margin-right: 5px"></label>ip白名单</label>
                <div class="col-md-6">
                    <input disabled type="text" class="form-control input-sm" id="security_ip" name="ipWhiteList"  value="${envAccessConfig.ipWhiteList}">
                    <span class="help-block"></span>
                </div>
            </div>
        </form>

        <form id="permiss" class="form-horizontal bg-info" style="padding: 20px">
            <div class="form-group">
                <label class="col-md-3 control-label">
                    <label class="text-danger" style="margin-right: 5px"></label>访问许可证号</label>
                <shiro:hasAnyRoles name="role_super_admin">
                    <div class="col-md-6">
                        <button  class="btn btn-primary btn-sm edit">修改</button>
                        <button  class="btn btn-primary btn-sm hide commit">确定</button>
                        <button  class="btn btn-primary btn-sm hide cancel">取消</button>
                    </div>
                </shiro:hasAnyRoles>
            </div>
            <div class="form-group">
                <label for="permiss_num" class="col-md-3 control-label">
                    <label class="text-danger" style="margin-right: 5px"></label>许可证号</label>
                <div class="col-md-6">
                    <input disabled type="text" class="form-control input-sm" id="permiss_num" name="permiss_num"  value="${authorCode}">
                    <span class="help-block"></span>
                </div>
            </div>
        </form>
    </div>
	</div>
</div>
<script type="text/javascript" src="<%=basePath%>/lib/jquery/1.11.0/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/lib/bootstrap/3.3.7/js/bootstrap.js"></script>
<script type="text/javascript" src="<%=basePath%>/lib/jquery.validation/1.14.0/jquery.validate_1.js"></script>
<script type="text/javascript" src="<%=basePath%>/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="<%=basePath%>/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="<%=basePath%>/lib/lobibox/js/lobibox.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/lib/lobibox/js/messageboxes.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/lib/lobibox/js/notifications.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/lib/JQuery.md5.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/common.js"></script>


<script type="text/javascript">

	 getAccessEnvMainListConfig()
    //记录edit时表单默认值
    var FromDataList={
			"saveAccessEnvMainListConfig": null,
            "sysCanConfigUserCount":null,
            "access_security":null,
            "access":null,
            "functional_access":null,
            "permiss":null,
			"business_config": null
        },
        //定义提交的地址
        AddressList={
			"saveAccessEnvMainListConfig": "<%=basePath%>/config/saveAccessEnvMainListConfig.do",
            "sysCanConfigUserCount":'<%=basePath%>/config/updateRoleUserCountLimit.do',
            "access_security":'<%=basePath%>/config/updateIpWhitelist.do',
            "access":'<%=basePath%>/config/updateSwitchAccessEnvConfig.do',
            "functional_access":'<%=basePath%>/config/updateDialogAccessEnvConfig.do',
            "permiss":'<%=basePath%>/config/updateAuthorCode.do',
			"business_config": '<%=basePath%>/config/updateBusinessConfig.do'
        },
        //定义验证变量
        ValidateList={
            "sysCanConfigUserCount":null,
            "access_security":null,
            "access":null,
            "functional_access":null,
            "permiss":null
        };
    $(function () {
        ValidateList.sysCanConfigUserCount=$("#sysCanConfigUserCount").validate({
            errorPlacement: function (error, element) {
                $(element)
                    .closest("div.form-group")
                    .find("span.help-block")
                    .append(error);
            },
            errorElement: "p",
            rules: {
//                maxDomainAdmin: {
//                    required: true,
//                    isGtNum:0,
//                    isInteger: true
//                },
                maxGeneralAdminCount: {
                    required: true,
                    isGtNum:0,
                    isInteger: true
                },
                maxTeamLeaderCount: {
                    required: true,
                    isGtNum:0,
                    isInteger: true
                },
                maxProfessionalsCount: {
                    required: true,
                    isGtNum:0,
                    isInteger: true
                }
            },
            messages: {
            }
        });

        ValidateList.access_security=$("#access_security").validate({
            errorPlacement: function (error, element) {
                $(element)
                    .closest("div.form-group")
                    .find("span.help-block")
                    .append(error);
            },
            errorElement: "p",
            rules: {
                ipWhiteList: {
                    required: false,
                    isIpList:true
                }
            },
            messages: {
            }
        });

        ValidateList.access=$("#access").validate({
            errorPlacement: function (error, element) {
                // Append error within linked label
                //console.log(element)
                $(element)
                    .closest("div.form-group")
                    .find("span.help-block")
                    .append(error);
            },
            errorElement: "p",
            rules: {
                minDuration:{
                    required: true,
                    isInteger:true
                },
                durationInterval:{
                    required: true,
                    isInteger:true
                },
                maxDuration:{
                    required: true,
                    isInteger:true
                }
            },
            messages: {
            }
        });

        ValidateList.functional_access=$("#functional_access").validate({
            errorPlacement: function (error, element) {
                $(element)
                    .closest("div.form-group")
                    .find("span.help-block")
                    .append(error);
            },
            errorElement: "p",
            rules: {
            },
            messages: {
            }
        });

        ValidateList.permiss=$("#permiss").validate({
            errorPlacement: function (error, element) {
                $(element)
                    .closest("div.form-group")
                    .find("span.help-block")
                    .append(error);
            },
            errorElement: "p",
            rules: {
                permiss_num: {
                    required: true
                }
            },
            messages: {
            }
        });

		$("input[name='showDialogInfoSwitch']").change(function() {
			var val = $(this).prop("checked");
			if(!val) {
				$("input[name='problemMarkSwitch']").prop("checked", false);
			}
		})

		$("input[name='problemMarkSwitch']").change(function() {
			var val = $(this).prop("checked");
			var showDialogInfoVal = $("input[name='showDialogInfoSwitch']").prop("checked");
			if(val&&!showDialogInfoVal) {
				$(this).prop("checked", false);
			}
		})

        $(".edit").on("click",function () {
            //修改事件
            var from=$(this).closest("form");
            from.find(":disabled").attr("disabled",false);
            getFromvalue(from)
            $(this).addClass("hide").nextAll().removeClass("hide");
            return false;
        })
        $("input[type='checkbox'][name='accessReportSwitch']").on("click",function () {
            isAccessReportSwitch(true);
        })
        $("input[type='checkbox'][name='showCallControlSwitch']").on("click",function () {
            isCallControlSwitch(true);
        })
        isAccessReportSwitch(false);
        isCallControlSwitch(false);
        $(".cancel").on("click",function (e) {
            //取消事件
            var from=$(this).closest("form");
            setFromvalue(from,FromDataList[from.attr("id")]);
            ValidateList[from.attr("id")].resetForm();
            if(from.is($("#access"))){
                isAccessReportSwitch(true);
            }
            from.find(".form-control,:checkbox").attr("disabled",true);
            $(this).addClass("hide").siblings(".commit").addClass("hide").siblings(".edit").removeClass("hide");
            return false;
        })

        $(".commit").on("click",function () {
            //提交事件
            var from=$(this).closest("form");
            var url=AddressList[from.attr("id")];
            var $this=this;
            if(from.valid()){
                $.ajax({
                    url:  url,
                    type: 'POST',
                    data: from.serialize(),
                    async: false,
                    // 这两个参数需要被定义，否则报错
                    success: function (data) {
                        if (data["errorCode"] == "0") {
                            myNotify("success", "", "修改成功");
                        } else {
                            myNotify("error", "", data["msg"])
                        }
                        getFromvalue(from);
                        from.find(".form-control,:checkbox").attr("disabled",true);
                        $($this).addClass("hide").siblings(".cancel").addClass("hide").siblings(".edit").removeClass("hide");
                    },
                    error: function () {
                        myNotify("error", "", "提交表单过程中过程中发生错误，请联系管理员！");
                    }
                });

            }else {
                myNotify("error", "", "请先修复错误后在进行提交");
            }
            return false
        })

        $(document).on("click", ".select_level_one_tit", function() {
            $(this).closest("td").find(".select_level_second").slideToggle(300);
        })

        $(".select_level_one").on("click", "input", function() {
            console.log($(this).prop("checked"))
            if(!$(this).prop("checked")) {
                $(this).closest("td").find(".select_level_second input").prop("checked",false);
            }
        })
    });
    /******************************方法声明**********************************/
    function setFromvalue($from,data) {
        $from.find(":checkbox").prop("checked",false)
        $.each(data,function (i,item) {
            var tempitem=$from.find(":checkbox[name='"+item.name+"'][value='"+item.value+"']")
            if(tempitem.size() > 0){
                tempitem.prop("checked",true);
            }else{
                $from.find("[name='"+item.name+"']").val(item.value);
            }
        })
    }

	function getAccessEnvMainListConfig() {
		$.ajax({
		    url: "<%=basePath%>/config/getAccessEnvMainListConfig.do",
		    type: "post",
		    async: false,
		    data: {

			},
		    dataType: "json",
		    success: function (data) {
		       if(data.errorCode == "0"){
		           var list = data.list;
				   var parentList = [];
				   var secondList = [];
                   var threeList = [];
				   $(list).each(function(index, item) {
					   if(item.parentId == 0) {
						   parentList.push(item)
					   }else {
						   secondList.push(item)
					   }
				   })

				   // 加载一级选项
				   var parentHtml = "";
				   $(parentList).each(function(index, item) {
					   var checked = '';
					   if(item.accessStatus == 0) {
						   checked = 'checked'
					   }
					   var itemHtml = ' <td accessCode="'+item.accessCode+'">'+
'                                <div class="select_level_one">'+
'                                    <input disabled="" type="checkbox" name="'+item.accessCode+'" value="'+item.accessStatus+'" '+checked+'> <span class="select_level_one_tit">'+item.accessName+'</span>'+
'                                </div>'+
// '                                <div class="select_level_second">'+
// '                                    <input disabled="" type="checkbox" name="showDialogViewSwitch" value="1" checked=""> 业务管理'+
// '                                    <!-- <input disabled type="checkbox"  name="showDialogViewSwitch" value="0" > 通话详情 -->'+
// '                                </div>'+
'                            </td>';
					   if((index+1)%4 == 1) {
							itemHtml = '<tr>'+itemHtml
					   }else if((index+1)%4 == 0) {
						  itemHtml = itemHtml+'</tr>'
					   }

					   if(index%4 != 0&&(index == parentList.length-1)) {
						    itemHtml = itemHtml+'</tr>'
					   }

					   parentHtml += itemHtml;
				   })

				   $("#accessEnvMainList").html(parentHtml);

				   // 加载二级选项
				   $(secondList).each(function(index, item) {
					   var checked = '';
					   if(item.accessStatus == 0) {
					   						   checked = 'checked'
					   }
					   var itemHtml = '                                <div class="select_level_second">'+
'                                    <input disabled="" type="checkbox" name="'+item.accessCode+'" value="'+item.accessStatus+'" '+checked+'> '+item.accessName+

'                                </div>'

						$('td[accessCode='+item.parentId+']').append(itemHtml)
				   })

		       }else{

		       }
		    },
		    error: function (data) {
		        myNotify("error", "", "向服务器发送删除请求过程中发生错误！");
		    }
		});
	}

    function getFromvalue(mfrom) {
        FromDataList[mfrom.attr("id")]=mfrom.serializeArray();
    }
    function isAccessReportSwitch(isReset) {
        //访问及许可权限--数据报表数据显示以及隐藏

        var $this=$("input[type='checkbox'][name='accessReportSwitch']");
        if($this.is(":checked")){
            $(".Conversation").show();
        }else{
            //重置数值
            if(isReset){
                //console.log(FromDataList.access)
                $.each(FromDataList.access,function (i,item) {
                    if($("input[name='"+item.name+"']").is(".Conversation input")){
                        $("input[name='"+item.name+"']").val(item.value)
                    }
                })
            }
            $(".Conversation").hide();
        }

    }
    function isCallControlSwitch(isReset) {
        var $this=$("input[type='checkbox'][name='showCallControlSwitch']");
        if($this.is(":checked")){
            $(".CallControl").show();
        }else{
            //重置数值
            if(isReset){
                //console.log(FromDataList.access)
                $.each(FromDataList.access,function (i,item) {
                    if($("input[name='"+item.name+"']").is(".Conversation input")){
                        $("input[name='"+item.name+"']").val(item.value)
                    }
                })
            }
            $(".CallControl").hide();
        }

    }
</script>

</body>
</html>